package com.intelligent.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;

/**
 * 应收明细表
 * @TableName receivable_detail
 */
@TableName(value ="receivable_detail")
@Data
public class ReceivableDetail implements Serializable {
    /**
     * 主键ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;



    /**
     * 客户ID（关联customer_info表的id）
     */
    private Long customerId;

    /**
     * 销售订单ID（关联sales_orders表的id，可为空，如非订单类应收）
     */
    private Long orderId;

    /**
     * 对账单ID（关联customer_reconciliation表的id，对账后关联）
     */
    private Long reconciliationId;

    /**
     * 应收类型：1-销售订单应收 2-服务费应收 3-其他应收
     */
    private Integer receivableType;

    /**
     * 应收总金额
     */
    private BigDecimal receivableAmount;

    /**
     * 已收金额
     */
    private BigDecimal receivedAmount;

    /**
     * 未收金额（自动计算：receivable_amount - received_amount）
     */
    private BigDecimal unreceivedAmount;

    /**
     * 应收日期（到期日）
     */
    private Date dueDate;

    /**
     * 收款状态：1-待收款 2-部分收款 3-已全额收款 4-坏账
     */
    private Integer status;

    /**
     * 付款条件（如：月结30天、款到发货）
     */
    private String paymentTerm;

    /**
     * 结算类型：0-现结 1-月结 2-货到付款（临时）
     */
    private Integer settlementType;

    /**
     * 备注（如：分期收款第1期）
     */
    private String remark;

    /**
     * 创建时间（应收产生时间）
     */
    private Date createTime;

    /**
     * 最后更新时间
     */
    private Date updateTime;

    /**
     * 创建人
     */
    private String creator;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ReceivableDetail other = (ReceivableDetail) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCustomerId() == null ? other.getCustomerId() == null : this.getCustomerId().equals(other.getCustomerId()))
            && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
            && (this.getReconciliationId() == null ? other.getReconciliationId() == null : this.getReconciliationId().equals(other.getReconciliationId()))
            && (this.getReceivableType() == null ? other.getReceivableType() == null : this.getReceivableType().equals(other.getReceivableType()))
            && (this.getReceivableAmount() == null ? other.getReceivableAmount() == null : this.getReceivableAmount().equals(other.getReceivableAmount()))
            && (this.getReceivedAmount() == null ? other.getReceivedAmount() == null : this.getReceivedAmount().equals(other.getReceivedAmount()))
            && (this.getUnreceivedAmount() == null ? other.getUnreceivedAmount() == null : this.getUnreceivedAmount().equals(other.getUnreceivedAmount()))
            && (this.getDueDate() == null ? other.getDueDate() == null : this.getDueDate().equals(other.getDueDate()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getPaymentTerm() == null ? other.getPaymentTerm() == null : this.getPaymentTerm().equals(other.getPaymentTerm()))
            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getCreator() == null ? other.getCreator() == null : this.getCreator().equals(other.getCreator()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCustomerId() == null) ? 0 : getCustomerId().hashCode());
        result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
        result = prime * result + ((getReconciliationId() == null) ? 0 : getReconciliationId().hashCode());
        result = prime * result + ((getReceivableType() == null) ? 0 : getReceivableType().hashCode());
        result = prime * result + ((getReceivableAmount() == null) ? 0 : getReceivableAmount().hashCode());
        result = prime * result + ((getReceivedAmount() == null) ? 0 : getReceivedAmount().hashCode());
        result = prime * result + ((getUnreceivedAmount() == null) ? 0 : getUnreceivedAmount().hashCode());
        result = prime * result + ((getDueDate() == null) ? 0 : getDueDate().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getPaymentTerm() == null) ? 0 : getPaymentTerm().hashCode());
        result = prime * result + ((getSettlementType() == null) ? 0 : getSettlementType().hashCode());
        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getCreator() == null) ? 0 : getCreator().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", customerId=").append(customerId);
        sb.append(", orderId=").append(orderId);
        sb.append(", reconciliationId=").append(reconciliationId);
        sb.append(", receivableType=").append(receivableType);
        sb.append(", receivableAmount=").append(receivableAmount);
        sb.append(", receivedAmount=").append(receivedAmount);
        sb.append(", unreceivedAmount=").append(unreceivedAmount);
        sb.append(", dueDate=").append(dueDate);
        sb.append(", status=").append(status);
        sb.append(", paymentTerm=").append(paymentTerm);
        sb.append(", settlementType=").append(settlementType);
        sb.append(", remark=").append(remark);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", creator=").append(creator);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
